<?php

include_once("config.php");
include_once("db_connect.php");
include_once("restrito.php");

$sql = "SELECT d.*, s.descr_protocolo_setor FROM ca_protocolo_despachante d, ca_protocolo_setor s WHERE d.id_protocolo_setor = s.id_protocolo_setor";

$result = mysql_query($sql);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Eventos Acadêmicos</title>
<link href="blueprint/screen.css" rel="stylesheet" type="text/css" media="all" />
<link href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.0/jquery.validate.js" ></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.js" ></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>

<script src="js/functions.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
		
		$.validator.addMethod('filesize', function(value, element, param) {
			// param = size (en bytes) 
			// element = element to validate (<input>)
			// value = value of the element (file name)
			return this.optional(element) || (element.files[0].size <= param) 
		});

        $('#form-questionario').validate({
            rules:{
                nome:{
                    required: true,
                    minlength: 3
                },
				email:{
                    required: true,
                    email: true
                },
				login:{
					required: true,
					minlength: 4,
					lettersonly: true
				},
				foto: {
				  accept: "image/*",
				  filesize: 1048576
				}
            },
            messages:{
                nome:{
                    required: "O campo nome é obrigatorio.",
                    minlength: "O campo nome deve conter no mínimo 3 caracteres."
				},
				email:{
                    required: "O campo email é obrigatorio.",
                    email: "Informe um email válido."
                },
				login:{
					required: "O campo login é obrigatorio.",
					minlength: "O campo login deve conter no mínimo 4 caracteres.",
					lettersonly: "Digite apenas letras."
				},
				foto: {
				  accept: "Apenas imagens são permitidas.",
				  filesize: "Imagem muito grande. Tamanho máximo 1MB."
				}
            }
 
        });
    });
</script>
</head>

<body>

<!--<div id="mask"></div>-->

<div id="wrapper">

<div id="header">
	<div id="logo_instituicao">
    	<img src="<?php echo $logo_instituicao; ?>" alt="Logo" />
    </div>
    <div id="logo_sistema">
    	<img src="<?php echo $logo_sistema; ?>" alt="" />
    </div>
</div>
<div id="content">
	<div id="sidebar">
    	<?php include("user_info_inc.php"); ?>
        <?php include("menu_inc.php"); ?>
    </div>
    <div id="main_content">
   	  <div id="notifications">
   	  <?php 
   	  	if(isset($_SESSION["system_info"]) && $_SESSION["system_info"] != ""){
			echo '<div class="info">'.$_SESSION["system_info"].'</div>';
		}
   	  ?>
   	  </div>
      

      
      
      <?php

if($_SESSION["req_user_id"] != ""){
	$dica = "Personalize seu perfil.</h4>";
	
	$id = $_SESSION["req_user_id"];
	$nome = $_SESSION["req_user_name"];
	$login = $_SESSION["req_user_login"];
	$email = $_SESSION["req_user_mail"];
}else{
	
}
?>

<div id="boxTitlePage">
	<span class="title">PERFIL</span>
	<span><?php echo $dica;?></span>
</div>

<?php
if(isset($_SESSION["tmp_password"]) && $_SESSION["tmp_password"] != ""){
	$tmp_senha = $_SESSION["tmp_password"];
    $_SESSION["tmp_password"] = null;
	echo '<div class="notice">Anote sua nova senha: <span style="font-weight:bold">'.$tmp_senha.'</span></div>';
}

?>

<?php
            if($_SESSION["req_user_photo"] != ""){
				echo '<img src="images/fotos/'.$_SESSION["req_user_photo"].'" alt="Foto" width="96" height="96" style="-webkit-border-radius: 99em; -moz-border-radius: 99em; border-radius: 99em;
border: 4px solid #fff;box-shadow: 0 3px 2px rgba(0, 0, 0, 0.3);"/><br />';
			}else{
				echo '<img src="avatar.jpg" alt=""  style="-webkit-border-radius: 99em; -moz-border-radius: 99em; border-radius: 99em;
border: 4px solid #fff;box-shadow: 0 3px 2px rgba(0, 0, 0, 0.3);"/><br />';
			}
            ?>

<form action="controller/usuarioController.php" id="form-questionario" method="post" enctype="multipart/form-data">
        	<input type="hidden" name="id" value="<?php echo $id; ?>"/>
            <input type="hidden" name="action" value="save_perfil"/>
            
            <label for="nome">Nome</label><br />
            <input type="text" value="<?php echo $nome;?>" name="nome" id="nome"/><br />
        	
        	<label for="email">Email</label><br />
            <input type="text" value="<?php echo $email;?>" name="email" id="email"/><br />
            
            <label for="login">Login</label><br />
            <input type="text" value="<?php echo $login;?>" name="login" id="login"/><br />
            
            <input type="checkbox" value="gerar" name="gerar_senha" id="gerar_senha"/><label for="gerar_senha">Gerar senha </label><span style="font-size:smaller">(Se marcado você receberá uma nova senha no email)</span><br />
            
            <br />
            
            
            <label for="foto">Foto</label><br />
            <input type="file" name="foto" id="foto"/><br />
            
            
            <br /><br />
            
                    
        	
        	<div id="barra_botoes">
            	<button class="botaoGoogleBlue float-right" type="submit" name="enviar">Salvar</button>
            	<button class="botaoGoogleBlue float-right" type="reset" name="cancelar">Cancelar</button>        	        
            </div>
            <div class="clear"></div>
            </form>
        
        
    </div>
</div>
<div id="footer">
	<div id="developers">
    	<img src="<?php echo $logo_developer; ?>" />
    </div>
    <div id="footer_address">
    	<?php echo $nome_faculdade_completo; ?><br />
        <?php echo $endereco_faculdade; ?>
    </div>
</div>
</div><!-- fecha wrapper-->

</body>
</html>
